using System;
using System.Collections.Generic;
using System.Text;

using System.Management.Automation;

namespace Microsoft.PowerShell.CmdletManagement
{
    [Cmdlet(VerbsCommon.Get, "PsSpecVerb")]
    public class GetPsSpecVerbCommand : PsSpecCommandBase
    {
        [Parameter(Mandatory = false, Position = 0, ValueFromPipelineByPropertyName = true)]
        [ValidateLength(1, 50)]
        public String Name
        {
            get
            {
                return _name;
            }
            set
            {
                _name = value;
            }
        }
        private string _name = "*";

        protected override void ProcessRecord()
        {
            PsSpecCmdletService.PsSpecVerb[] verbs = null;

            verbs = this.Service.GetVerb(
                PsSpecCmdletUtils.ConvertWildcardToSqlWildcard(Name));

            foreach (PsSpecCmdletService.PsSpecVerb verb in verbs)
            {
                WriteObject(new PsSpecVerb(
                    verb.Type, 
                    verb.Name, 
                    verb.Definition, 
                    verb.Comments, 
                    verb.Obsoletes, 
                    verb.Pair));
            }
        }
    }
}
